package com.ruoyi.web.controller.eamp;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.entity.SysDept;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.eamp.domain.EampClassManage;
import com.ruoyi.eamp.domain.vo.MangeAndListVO;
import com.ruoyi.eamp.domain.vo.UserAndDeptAndManageVO;
import com.ruoyi.eamp.service.IEampClassDateService;
import com.ruoyi.eamp.service.IEampClassManageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 排班值班关系表Controller
 * 
 * @author ruoyi
 * @date 2024-08-08
 */
@RestController
@RequestMapping("/eamp/class_manage")
public class EampClassManageController extends BaseController
{
    @Autowired
    private IEampClassManageService eampClassManageService;

    @Autowired
    private IEampClassDateService eampClassDateService;

    /**
     * 查询排班值班关系表列表
     */
    @PreAuthorize("@ss.hasPermi('eamp:class_manage:list')")
    @GetMapping("/list")
    public TableDataInfo list(EampClassManage eampClassManage)
    {
        startPage();
        List<EampClassManage> list = eampClassManageService.selectEampClassManageList(eampClassManage);
        return getDataTable(list);
    }

    /**
     * 导出排班值班关系表列表
     */
    @PreAuthorize("@ss.hasPermi('eamp:class_manage:export')")
    @Log(title = "排班值班关系表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, EampClassManage eampClassManage)
    {
        List<EampClassManage> list = eampClassManageService.selectEampClassManageList(eampClassManage);
        ExcelUtil<EampClassManage> util = new ExcelUtil<EampClassManage>(EampClassManage.class);
        util.exportExcel(response, list, "排班值班关系表数据");
    }

    /**
     * 获取排班值班关系表详细信息
     */
    @PreAuthorize("@ss.hasPermi('eamp:class_manage:query')")
    @GetMapping(value = "/{classId}")
    public AjaxResult getInfo(@PathVariable("classId") Long classId)
    {
        return success(eampClassManageService.selectEampClassManageByClassId(classId));
    }

    /**
     * 新增排班值班关系表
     */
    @PreAuthorize("@ss.hasPermi('eamp:class_manage:add')")
    @Log(title = "排班值班关系表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody EampClassManage eampClassManage)
    {

        return toAjax(eampClassManageService.insertEampClassManage(eampClassManage));
    }

    /**
     * 修改排班值班关系表
     */
    @PreAuthorize("@ss.hasPermi('eamp:class_manage:edit')")
    @Log(title = "排班值班关系表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody EampClassManage eampClassManage)
    {
        return toAjax(eampClassManageService.updateEampClassManage(eampClassManage));
    }

    /**
     * 删除排班值班关系表
     */
    @PreAuthorize("@ss.hasPermi('eamp:class_manage:remove')")
    @Log(title = "排班值班关系表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{classIds}")
    public AjaxResult remove(@PathVariable Long[] classIds)
    {
        return toAjax(eampClassManageService.deleteEampClassManageByClassIds(classIds));
    }

    /**
     *排班申请
     */
    @PreAuthorize("@ss.hasPermi('eamp:class_manage:applySend')")
    @Log(title = "排班申请", businessType = BusinessType.INSERT)
    @PostMapping("/applySend")
    public AjaxResult applySend(@RequestBody MangeAndListVO mangeAndListVO)
    {

        System.out.println(mangeAndListVO);
        // List<List> alist =eampClassManage.getClassAffiliation()
        int i=eampClassManageService.applySend(mangeAndListVO);
        return toAjax(i);



    }
    //部门查询
    @PreAuthorize("@ss.hasPermi('eamp:class_manage:getAffiliation')")
    @PostMapping("/getAffiliation")
    public TableDataInfo getDept()
    {
        List<SysDept> list=eampClassManageService.getDept();
        return getDataTable(list);
    }



    //联查部门
    @GetMapping("/getUsAndDe")
    public TableDataInfo getUsAndDe(UserAndDeptAndManageVO userAndDeptAndManageVO)
    {
        startPage();
        List<UserAndDeptAndManageVO> list = eampClassManageService.getUsAndDe(userAndDeptAndManageVO);
        return getDataTable(list);
    }




}
